package it.ap.sa.acqua.plant.service.converter;

import org.springframework.stereotype.Component;

import it.ap.sa.acqua.dao.beans.TPlantBean;
import it.ap.sa.acqua.dao.model.TPlant;
import it.ap.sa.core.util.IBeanPopulate;

/**
 * Converter tra {@link TPlant} e {@link TPlantBean}
 * @author Alessandro Paolillo
 */
@Component
public class PlantConverter implements IBeanPopulate<TPlant, TPlantBean>{

	public PlantConverter() {
	}

	/**
	 * @author Alessandro Paolillo
	 * @see it.eng.tz.core.util.IBeanPopulate#convertdbToPage(java.lang.Object)
	 */
	@Override
	public TPlantBean convertdbToPage(TPlant src) throws Exception {
		TPlantBean result = new TPlantBean();
		result.setId( src.getId() );
		result.setCareLevel( src.getCareLevel() );
		result.setCo2( src.getCo2() );
		result.setDescription( src.getDescription() );
		result.setGhMax( src.getGhMax() );
		result.setGhMin( src.getGhMin() );
		result.setGrowThrate( src.getGrowThrate() );
		result.setIdFamily( src.getIdFamily() );
		result.setKhMax( new Double(src.getKhMax()) );
		result.setKhMin( new Double(src.getKhMin()) );
		result.setLighting( src.getLighting() );
		result.setOrigin( src.getOrigin() );
		result.setOriginZone( src.getOriginZone() );
		result.setPhMax( src.getPhMax() );
		result.setPhMin( src.getPhMin() );
		result.setScientificName( src.getScientificName() );
		result.setTemperatureMax( src.getTemperatureMax() );
		result.setTemperatureMin( src.getTemperatureMin() );
		return result;
	}
	
	/**
	 * @author Alessandro Paolillo
	 * @see it.eng.tz.core.util.IBeanPopulate#convertpageToDb(java.lang.Object)
	 */
	@Override
	public TPlant convertpageToDb(TPlantBean src) throws Exception {
		TPlant result = new TPlant();
		result.setId( src.getId() );
		result.setCareLevel( src.getCareLevel() );
		result.setCo2( src.getCo2() );
		result.setDescription( src.getDescription() );
		result.setGhMax( src.getGhMax() );
		result.setGhMin( src.getGhMin() );
		result.setGrowThrate( src.getGrowThrate() );
		result.setIdFamily( src.getIdFamily() );
		result.setKhMax( new Double(src.getKhMax()) );
		result.setKhMin( new Double(src.getKhMin()) );
		result.setLighting( src.getLighting() );
		result.setOrigin( src.getOrigin() );
		result.setOriginZone( src.getOriginZone() );
		result.setPhMax( src.getPhMax() );
		result.setPhMin( src.getPhMin() );
		result.setScientificName( src.getScientificName() );
		result.setTemperatureMax( src.getTemperatureMax() );
		result.setTemperatureMin( src.getTemperatureMin() );
		return result;
	}
}
